/**
 * Project Name:Micro-Services-RPC-Message
 * File Name   :BaseDto.java
 * Package Name:com.micro.services.rpc
 * Date:2015-9-9上午9:20:27
 * Copyright (c) 2015, http://my.oschina.net/httpssl All Rights Reserved.
 *
*/

package com.micro.services.rpc;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;

import org.apache.commons.lang3.builder.CompareToBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * ClassName:BaseDto <br/>
 * Function :TODO ADD FUNCTION. <br/>
 * Reason	:TODO ADD REASON. <br/>
 * Date     :2015-9-9 上午9:20:27 <br/>
 * @author  :http://my.oschina.net/httpssl
 * @email   :491835898@QQ.COM
 * @since   :JDK 1.7
 * @see 	 
 */
public class BaseDto implements Comparator<BaseDto>
{
	private Collection<String> excludeFields = new HashSet<>();
	
	public BaseDto() {
		this("excludeFields");
	}
	
	public BaseDto(final String ...fields)
	{
		excludeFields.addAll(Arrays.asList(fields));
		this.excludeFields.add("excludeFields");
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return ReflectionToStringBuilder.toStringExclude(this, excludeFields);
	}
	
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		return  EqualsBuilder.reflectionEquals(this, obj, excludeFields);
	}
	
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return HashCodeBuilder.reflectionHashCode(this, excludeFields);
	}

	@Override
	public int compare(BaseDto one, BaseDto another) {
		// TODO Auto-generated method stub
		return CompareToBuilder.reflectionCompare(one, another, excludeFields);
	}
  
	
}
